﻿using Common.Dtos;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sigma.Admin.Client
{
    public sealed class AppSession: BindableBase
    {
        private static readonly AppSession instance = new AppSession();
        private AppSession() { }

        public static AppSession Instance
        {
            get
            {
                return instance;
            }
        }

        public int? UserId { get; set; }
        private string _userName;

        public string UserName
        {
            get { return _userName; }
            set { _userName = value; RaisePropertyChanged(); }
        }


        public string Token { get; set; }

        public static TokenDto GetTokenPayload()
        {
            var Payload = Jose.JWT.Payload<TokenDto>(instance.Token);
            return Payload;
        }

        public static void Clear()
        {
            instance.UserName =null;
            instance.UserId = null;
            instance.Token = null;
        }
        
    }
}
